Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

214
Visualizações
Trying to use "Socket.io-client" module in React throws error: Cannot assign to read only property 'exports' of object '#<Object>'

I'm using socket.io-client in my React js web app. It compiles without error, but when I try to open the development server (localhost:3000) I get the following error:

Error Screenshot

In this project where the error is being thrown, here is a list of the relevant packages and their versions:

  • @testing-library/jest-dom@5.14.1
  • @testing-library/react@11.2.7
  • @testing-library/user-event@12.8.3
  • react-dom@17.0.2
  • react-scripts@4.0.3
  • react@17.0.2
  • socket.io-client@4.3.1

Webpack Version: 4.44.2


Threads like this one suggest that this is some sort of issue with mixing import and module.exports in ES6, but I definitely don't want to modify the socket.io-client module.

In a previous React project, where the module works, here is a list of the relevant packages and their versions:

  • @testing-library/jest-dom@4.2.4
  • @testing-library/react@9.5.0
  • @testing-library/user-event@7.2.1
  • react-scripts@3.4.4
  • react@16.14.0
  • socket.io-client@4.1.2

Webpack Version: 4.42.0

I've played around a little bit with different versions of socket.io-client and react to try to get it working, but to no avail...

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Webpack uses ES syntax, so commonJS syntax will not work.

export default lookup
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda